#include <cstdio>

char maze[8][8];
int n, m, t;
bool success_flag;
int go[][2] = {1, 0, -1, 0, 0, 1, 0, -1};
void DFS(int x, int y, int time);

int main(int argc, char const *argv[]){
    while(scanf("%d%d%d", &n, &m, &t) != EOF){
        if (n == 0 && m == 0 && t == 0)
            break;
        for (int i = 1; i <= n; i++)
            scanf("%s", maze[i] + 1);
        success_flag = false;
        int start_x, start_y;
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= m; j++){
                if (maze[i][j] == 'D'){
                    start_x = i;
                    start_y = j;
                }
            }
        }
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= m; j++){
                if (maze[i][j] == 'S' && (i + j) % 2 == ((start_x + start_y) % 2 + t % 2) % 2){
                    maze[i][j] = 'X';
                    DFS(i, j, 0);
                }
            }
        }
        puts(success_flag == true ? "YES" : "NO");
    }
    return 0;
}
void DFS(int x, int y, int time){
    for (int i = 0; i < 4; i++){
        int next_x = x + go[i][0];
        int next_y = y + go[i][1];
        if (next_x < 1 || next_x > n || next_y < 1 || next_y > m)
            continue;
        if (maze[next_x][next_y] == 'X')continue;
        if (maze[next_x][next_y] == 'D'){
            if (time + 1 == t){
               success_flag = true;
               return;
            }
            else
                continue;
        }
        maze[next_x][next_y] = 'X';
        DFS(next_x, next_y, time + 1);
        maze[next_x][next_y] = '.';
        if (success_flag)
            return;
    }
}
